import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const loadComponent = (comName) => {
	return () => {
		return import(`@/components/${comName}.vue`)
	}
}


const router = createRouter({
	history: createWebHashHistory(),
	routes: [
		{
			path: '/',
			redirect: '/home'
		},
		{
			path: '/home',
			name: 'Home',
			component: HomeView,
			children: [
				{
					path: '',
					component: import('@/components/dd/PutonDd.vue')
				},
				{
					path: 'putondd',
					name: 'PutonDd',
					component: import('@/components/dd/PutonDd.vue')
				},
				{
					path: 'miaodd',
					name: 'MiaoDd',
					component: import('@/components/dd/MiaoDd.vue')
				},
				{
					path: 'putonshop',
					name: 'PutonShop',
					component: import('@/components/shop/PutonShop.vue')
				},
				{
					path: 'miaoshop',
					name: 'MiaoShop',
					component: import('@/components/shop/MiaoShop.vue')
				},
				{
					path: 'dayshop',
					name: 'DayShop',
					component: import('@/components/shop/DayShop.vue')
				},
				{
					path: 'goryshop',
					name: 'GoryShop',
					component: import('@/components/shop/GoryShop.vue')
				},
				{
					path: 'managerlist',
					name: 'ManagerList',
					component: import('@/components/manager/ManagerList.vue')
				},
				{
					path: 'addmanager',
					name: 'AddManager',
					component: import('@/components/manager/AddManager.vue')
				},
				{
					path: 'managerdd',
					name: 'ManagerDd',
					component: import('@/components/manager/ManagerDd.vue')
				},
				{
					path: 'payinfo',
					name: 'PayInfo',
					component: import('@/components/pay/PayInfo.vue')
				},
				{
					path: 'paylist',
					name: 'PayList',
					component: import('@/components/pay/PayList.vue')
				},
				{
					path: 'datachart',
					name: 'DataChart',
					component:import('@/components/data/DataChart.vue')
				}
			]
		},
		{
			path: '/:catchAll(.*)',
			component: () => import('@/views/error/404.vue')
		}
	]
})

// router.beforeEach((to,form,next)=>{
// 	if(to.path == '/'){
// 		console.log(123);
// 		next({path: '/home'})
// 	}
// 	// console.log(to.path == '/');
// 	// console.log(form);
// 	// console.log(next);
	
// })

export default router